"""CreateUserTable Migration."""

from masoniteorm.migrations import Migration


class CreateUserTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with self.schema.create("users") as table:
            table.table_comment("会员表")
            table.increments("id")
            table.string('account', 15, False).comment('账户')
            table.string('password', 255, True).comment('密码')
            table.string('nickname', 32, True).comment('昵称')
            table.string('salt', 8, False).comment('加密盐')
            table.tiny_integer('is_lock', 1, False).default(0).comment('锁定')
            table.tiny_integer('is_deleted', 1, False).default(0).comment('删除')

            table.timestamps()
            table.unique('account', 'uni_account')

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop("users")
